﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace DataObject.Image
{
    public class ImageDAL
    {
        /***************************************
        = Back End
        -------------------------------------- */
        public static void Image_Create(ImageObject o)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Image_Create", o.ProductId, o.Priority, o.ImagePath);
        }

        public static void Image_Delete(int imageId)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Image_Delete", imageId);
        }

        public static int Image_GetImageCount(int productId)
        {
            return (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Image_GetImageCount", productId);
        }

        public static IDataReader Image_GetById(int imageId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Image_GetById", imageId);
        }

        public static IDataReader Image_GetByProductId(int productId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Image_GetByProductId", productId);
        }
    }
}
